var MinStack = function() {
  this.arr = [];
};

/**
 * @param {number} val
 * @return {void}
 */
MinStack.prototype.push = function(val) {
  this.arr[this.arr.length] = val;
};

/**
 * @return {void}
 */
MinStack.prototype.pop = function() {
  if(this.arr.length)
    this.arr = this.arr.slice(0, this.arr.length - 1);
  return null;
};

/**
 * @return {number}
 */
MinStack.prototype.top = function() {
  if(this.arr.length)
    return this.arr[this.arr.length - 1];
  else
    return null;
};

/**
 * @return {number}
 */
MinStack.prototype.getMin = function() {
  if(!this.arr.length) return null;
  console.log(this.arr);
  let min = this.arr[0];
  for(let i = 1; i < this.arr.length; i++) {
    if(min > this.arr[i])
      min = this.arr[i];
  }
  return min;
};

/**
 * Your MinStack object will be instantiated and called as such:
 * var obj = new MinStack()
 * obj.push(val)
 * obj.pop()
 * var param_3 = obj.top()
 * var param_4 = obj.getMin()
 */
// let test = new MinStack();
// test.push(-2);
// test.push(0);
// test.push(-3);
// console.log(test.getMin());
// test.pop();
// console.log(test.top());
// console.log(test.getMin());
